//
//  ZhanDuiViewController.m
//  A_HandHeldLOL
//
//  Created by Zhao YanBin on 16/1/20.
//  Copyright © 2016年 zhaoyanbin. All rights reserved.
//

#import "ZhanDuiViewController.h"
#import "AFNModel.h"
#import "ZhanDuiziliaoModel.h"
#import <UIImageView+WebCache.h>

#import "FazhanViewController.h"
#import "XianyiViewController.h"
#import "HuojiangViewController.h"
@interface ZhanDuiViewController ()
//头部
@property(nonatomic, retain)UIImageView *img;
@property(nonatomic, retain)UILabel *name;
@property(nonatomic, retain)UILabel *neirong;

//下方三个按钮
@property(nonatomic, retain)UIButton *fazhan;
@property(nonatomic, retain)UIButton *xianyi;
@property(nonatomic, retain)UIButton *huojiang;

@property(nonatomic, retain)NSDictionary *dic;
@end

@implementation ZhanDuiViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    //头部信息
    [self head];
    
    //网络获取
    [self data];
}

-(void)head
{
    self.img = [[UIImageView alloc] initWithFrame:CGRectMake(10, 74, 70, 70)];
    _img.backgroundColor = [UIColor redColor];
    [self.view addSubview:_img];
    [_img release];
    
    self.name = [[UILabel alloc] initWithFrame:CGRectMake(100, 84, 250, 50)];
    _name.backgroundColor = [UIColor blueColor];
    [self.view addSubview:_name];
    [_name release];
    
    self.neirong = [[UILabel alloc] initWithFrame:CGRectMake(10, 160, 350, 200)];
    _neirong.backgroundColor = [UIColor yellowColor];
    self.neirong.numberOfLines = 0;
    [self.view addSubview:_neirong];
    [_neirong release];
    
    self.fazhan = [UIButton buttonWithType:UIButtonTypeCustom];
    _fazhan.frame = CGRectMake(0, 400, self.view.frame.size.width, 50);
   [_fazhan setTitle:@"发展状况" forState:UIControlStateNormal];
    [_fazhan addTarget:self action:@selector(fazhan:) forControlEvents:UIControlEventTouchUpInside];
    _fazhan.backgroundColor = [UIColor grayColor];
    [self.view addSubview:_fazhan];
    
    self.xianyi = [UIButton buttonWithType:UIButtonTypeCustom];
    _xianyi.frame = CGRectMake(0, 450, self.view.frame.size.width, 50);
    [_xianyi setTitle:@"现役队员" forState:UIControlStateNormal];
    [_xianyi addTarget:self action:@selector(xianyi:) forControlEvents:UIControlEventTouchUpInside];
    _xianyi.backgroundColor = [UIColor blueColor];
    [self.view addSubview:_xianyi];
    
    self.huojiang = [UIButton buttonWithType:UIButtonTypeCustom];
    _huojiang.frame = CGRectMake(0, 500, self.view.frame.size.width, 50);
    [_huojiang setTitle:@"获奖荣誉" forState:UIControlStateNormal];
    [_huojiang addTarget:self action:@selector(huojiang:) forControlEvents:UIControlEventTouchUpInside];
    _huojiang.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:_huojiang];
    
}

//跳转发展状况页面
-(void)fazhan:(UIButton *)btn
{
    FazhanViewController *fazhanVC = [[FazhanViewController alloc] init];
    fazhanVC.detailsid = _detailsid;
    [self.navigationController pushViewController:fazhanVC animated:YES];
}

//跳转现役队员页面
-(void)xianyi:(UIButton *)btn
{
    XianyiViewController *xianyiVC = [[XianyiViewController alloc] init];
    xianyiVC.detailsid = _detailsid;
    [self.navigationController pushViewController:xianyiVC animated:YES];
}


//跳转获奖荣誉页面
-(void)huojiang:(UIButton *)btn
{
    HuojiangViewController *huojiangVC = [[HuojiangViewController alloc] init];
    huojiangVC.detailsid = _detailsid;
    [self.navigationController pushViewController:huojiangVC animated:YES];
}

//网络获取
-(void)data
{
    NSString *str1 = @"http://qt.qq.com/php_cgi/lol_mobile/club/varcache_team_info.php?id=";
    NSString *str2 = @"&version=3&plat=ios";
    NSString *str = [NSString stringWithFormat:@"%@%@%@",str1,_detailsid,str2];
    [AFNModel GETWithURL:str completion:^(id result) {
        self.dic = result;
        NSLog(@"%@", result);
        [self ziliao];
    }];
}
-(void)ziliao
{
    if (self.dic != nil) {
        self.navigationItem.title = [_dic objectForKey:@"name" ];
        _name.text = [self.dic objectForKey:@"full_name"];
        [_img sd_setImageWithURL:[NSURL URLWithString:_dic[@"iconUrl"]]];
        _neirong.text = [self.dic objectForKey:@"desc"];
    }
    

}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
